package com.zr.command.aspect;
import com.alibaba.fastjson2.JSON;
import com.zr.command.websocket.WebSocketServer;
import com.zr.common.utils.SecurityUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 操作指挥调度工单
 *
 */
@Aspect
@Component
public class EimCommandScheduleAspect {


    @Autowired
    private WebSocketServer webSocketServer;

    /**
     *流调到新增病例后，监测往数据库新增病例数量
     *
     * @param joinPoint 切点
     */
    @AfterReturning(value = "execution(* com.zr.command.service..*.insertEimCommandSchedulesByCovidFlow(..))", returning = "jsonResult")
    public void AfterReturning(JoinPoint joinPoint, Object jsonResult) {
        String token = SecurityUtils.getLoginUser().getToken();
        webSocketServer.sendMessage(JSON.toJSONString(jsonResult),token);
    }



}
